<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$operation = $_GPC['op'];
$user_id = $_GPC['id'];
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$where=' WHERE  uniacid=:uniacid and user_id=:user_id';
$data[':uniacid']=$_W['uniacid'];
$data[':user_id']=$user_id;
if(!empty($_GPC['time'])){
    $start=strtotime($_GPC['time']['start']);
    $end=strtotime($_GPC['time']['end']);
    $where.=" and UNIX_TIMESTAMP(cerated_time) >={$start} and UNIX_TIMESTAMP(cerated_time)<={$end}";
    }
if($operation=="jifen"){
    $where.=' and category_type="integral"';
    $sql="SELECT * FROM ".tablename('zhtc_integral') .  "  ". $where." ORDER BY id DESC";
    $total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zhtc_integral') ."".$where." ORDER BY id DESC",$data);
}
if($operation=="consume"){
    $where.=' and category_type="consume"';
    $sql="SELECT * FROM ".tablename('zhtc_integral') .  "  ". $where." ORDER BY id DESC";
    $total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zhtc_integral') ."".$where." ORDER BY id DESC",$data);
}
$list=pdo_fetchall( $sql,$data);
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list=pdo_fetchall($select_sql,$data);
$pager = pagination($total, $pageindex, $pagesize);

include $this->template('web/userjifen');
